<?php
/**
 * CompleXml Framework
 *
 * @category   CompleXml
 * @package    CompleXml_Handler
 * @copyright  Copyright (c) 2008 Andrey Kucherenko
 * @license    New BSD License
 * @version    $Id: Browser.php 9 2008-11-16 17:58:08Z kucherenko.andrey $
 */
require_once 'CompleXml/Handler/Output/Abstract.php';
class CompleXml_Handler_Output_Browser extends CompleXml_Handler_Output_Abstract {
	/**
	 * Path to templates
	 *
	 * @var string
	 */
	protected $_template_path;

	public function execute(CompleXml_Object_Abstract $Object) {
		if (! ($Object instanceof CompleXml_Object_Controller)) {
			throw new CompleXml_Object_Exception ( 'Object not Controller' );
		}
		$xmlString = $Object->View->getXml ();
		$file = $Object->View->getTemplate().'.xsl';
		$xml = new DomDocument ( );
		$xml->loadXML ( $xmlString );
		@$xml->xinclude ();
		$outputXml = $xml->saveXML ();
		$outputXml = str_replace('?>', '?><?xml-stylesheet type="text/xsl" href="'.$file.'"?>', $outputXml);
		header ( "Content-type: text/xml" );
		$Object->Response->nocache ();
		echo $outputXml;
	}
}